#ifndef CDNPROFILERFN_H
#define CDNPROFILERFN_H

#include <map>
#include <string>
#include <windows.h>

namespace prof
{
	class CdnProfTimer;

	class CdnProfilerFn
	{
	public:

		typedef std::map<std::string, CdnProfilerFn*> ChildrenList;

		CdnProfilerFn(const char* name, CdnProfilerFn* pParent = 0);
		~CdnProfilerFn();

		CdnProfilerFn* GetParent()
		{
			return m_pParent;
		}

		const ChildrenList& GetChildren() const
		{
			return m_children;
		}

		const char* GetName() const
		{
			return m_name.c_str();
		}

		void Start();
		void Stop();
		CdnProfilerFn* StartChildFunction(const char* name);
		void StopChildFunction(const char* name);		

		float GetTotalTime() const
		{
			return m_myProcessingTime;
		}

		float GetTotalTimeNoChildren() const
		{
			return m_myProcessingTime - m_childrenElapsedTime;
		}

	private:

		std::string m_name;
		ChildrenList m_children;

		CdnProfilerFn* m_pParent;
		CdnProfTimer* m_pTimer;

		float m_childrenElapsedTime;
		float m_myProcessingTime;

	};
}


#endif